package com.dao.job.pa.support;

import java.sql.SQLException;
import java.util.List;

import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.springframework.orm.hibernate3.HibernateCallback;

import com.dao.job.pa.IJobPriviledgeDao;
import com.dao.spring.BaseDao;
import com.pojo.job.pa.PAJobPriviledge;

public class JobPriviledgeDao extends BaseDao implements IJobPriviledgeDao {

	@SuppressWarnings("unchecked")
	public List<PAJobPriviledge> findByRightJoinSALM(Integer PA_MENU_ID,Integer IS_ET) {
		return super.getHibernateTemplate().find("from PAJobPriviledge pjp right join fetch pjp.SALM where pjp.PA_MENU_ID="+PA_MENU_ID+" and pjp.IS_ET="+IS_ET+"");
	}

	public void sava(PAJobPriviledge pjp) {
		super.getHibernateTemplate().save(pjp);
	}

	@SuppressWarnings({ "unchecked", "rawtypes" })
	public void delete(final Integer menuId,final Integer IS_ET) {
		super.getHibernateTemplate().execute(new HibernateCallback(){
			public Object doInHibernate(Session session)throws HibernateException, SQLException {
				session.createQuery("delete from PAJobPriviledge as pjp where pjp.PA_MENU_ID="+menuId+" and pjp.IS_ET="+IS_ET+"").executeUpdate();
				return null;
			}
		});
	}

	
}
